import json

from sortedcontainers import SortedDict


class RangeModule:

    def __init__(self):
        self.intervals = SortedDict()

    def addRange(self, left: int, right: int) -> None:
        itvs_ = self.intervals

        x = itvs_.bisect_right(left)
        if x != 0:
            start = x - 1
            if itvs_.values()[start] >= right:
                return
            if itvs_.values()[start] >= left:
                left = itvs_.keys()[start]
                itvs_.popitem(start)
                x -= 1

        while x < len(itvs_) and itvs_.keys()[x] <= right:
            right = max(right, itvs_.values()[x])
            itvs_.popitem(x)

        itvs_[left] = right

    def queryRange(self, left: int, right: int) -> bool:
        itvs_ = self.intervals

        x = itvs_.bisect_right(left)
        if x == 0:
            return False

        return right <= itvs_.values()[x - 1]

    def removeRange(self, left: int, right: int) -> None:
        itvs_ = self.intervals

        x = itvs_.bisect_right(left)
        if x != 0:
            start = x - 1

            ri = itvs_.values()[start]
            if ri >= right:
                li = itvs_.keys()[start]
                if li == left:
                    itvs_.popitem(start)
                else:
                    itvs_[li] = left
                if right != ri:
                    itvs_[right] = ri
                # 这个返回啥，不写返回空了?！
                return
            # 目前用的python 3.7，海象运算符:= python 3.8开始支持：
            # if (ri := itvs_.values()[start]) >= right:
            #     if (li := itvs_.keys()[start]) == left:
            #         itvs_.popitem(start)
            #     else:
            #         itvs_[li] = left
            #     if right != ri:
            #         itvs_[right] = ri
            #     return
            elif ri > left:
                itvs_[itvs_.keys()[start]] = left

        while x < len(itvs_) and itvs_.keys()[x] < right:
            if itvs_.values()[x] <= right:
                itvs_.popitem(x)
            else:
                itvs_[right] = itvs_.values()[x]
                itvs_.popitem(x)
                break

def main():
    import sys
    import io
    def readLines():
        for line in io.TextIOWrapper(sys.stdin.buffer, encoding="utf-8"):
            yield line.strip("\n")

    lines = readLines()
    while True:
        try:
            line = next(lines)
            # 开始 调用类方法
            commands = json.loads(line)
            arrays = json.loads(next(lines))

            res = []
            s = ""
            for i, c in enumerate(commands):
                if c == "RangeModule":
                    s = RangeModule()
                    res.append(None)
                elif c == "addRange":
                    r = s.addRange(arrays[i][0], arrays[i][1])
                    res.append(r)
                elif c == "removeRange":
                    r = s.removeRange(arrays[i][0], arrays[i][1])
                    res.append(r)
                elif c == "queryRange":
                    r = s.queryRange(arrays[i][0], arrays[i][1])
                    res.append(r)
            print(res)
        except StopIteration:
            break


if __name__ == '__main__':
    # ["RangeModule","addRange","removeRange","queryRange","queryRange","queryRange"]
    # [[],[10,20],[14,16],[10,14],[13,15],[16,17]]
    main()
